View Javadoc

1   /*
2    * Copyright (c) 2004-2005, University Health Network.  All rights reserved. Distributed under the BSD 
3    * license (see http://opensource.org/licenses/bsd-license.php).
4    *  
5    * Created on 25-Jan-2005
6    */
7   package ca.uhn.cache.util;
8   
9   import java.util.Iterator;
10  
11  /***
12   * An extension of Iterator that allows additions during iteration.  For 
13   * example one thread could populate the iterator while another iterates through it.      
14   *  
15   * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
16   * @version $Revision: 1.1 $ updated on $Date: 2005/01/26 00:25:50 $ by $Author: bryan_tripp $
17   */
18  public interface IMutableIterator extends Iterator {
19  
20      /***
21       * Adds a single item to the list which this iterator iterates through. 
22       *   
23       * @param theItem IDataItem to add
24       */
25      public void add(Object theItem);
26      
27      /***
28       * Called after all add() and merge() calls.  The add() and merge() methods 
29       * may not be called after this.  
30       * 
31       * This method MUST be called when additions are complete, or else hasNext() will 
32       * pend indefinitely.  This is because if further additions are possible, hasNext() 
33       * is undefined.    
34       */
35      public void freeze();
36      
37      /***
38       * This indicates that an exception has been encountered while populating this iterator.
39       * A MutableIteratorException wrapping this one will be thrown on the next call to next().  
40       *  
41       * @param theException exception to declare
42       */
43      public void declareException(Exception theException);
44  
45      /***
46       * Releases any resources held by this iterator.  Should be called if iteration 
47       * is being aborted.  If called during iteration, the results may be incomplete.  
48       */
49      public void close();
50  
51  }